Imports BusinessLayer
Imports EntityLayer
Imports System.Data

Partial Class VistaOrdenCompra
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Dim intNumOrden As Integer
            intNumOrden = CInt(Request.QueryString("strCodigo"))

            Dim dt As DataTable
            dt = OrdenCompraBL.SeleccionarxCodigo(intNumOrden).Tables(0)

            txtNumero.Text = dt.Rows(0)("Numero").ToString.Trim.PadLeft(4, "0")
            hdnCodigo.Value = dt.Rows(0)("Numero").ToString
            txtFecha.Text = dt.Rows(0)("FechaEmision").ToString
            txtProveedor.Text = dt.Rows(0)("razonSocial").ToString
            txtFormaPago.Text = dt.Rows(0)("FormaPago").ToString
            txtPlazoEntrega.Text = dt.Rows(0)("PlazoEntrega").ToString
            txtSolicitante.Text = dt.Rows(0)("Solicitante").ToString
            txtArea.Text = dt.Rows(0)("Area").ToString
            txtNumeroCuenta.Text = dt.Rows(0)("NumeroCuenta").ToString
            txtNumeroCotizacion.Text = dt.Rows(0)("NumeroCotizacion").ToString
            lblSubTotal.Text = String.Format("{0:0.00}", CDbl(dt.Rows(0)("subtotal").ToString))
            lblIGV.Text = String.Format("{0:0.00}", CDbl(dt.Rows(0)("igv").ToString))
            lblTotal.Text = String.Format("{0:0.00}", CDbl(dt.Rows(0)("total").ToString))

            Session("myDatatable") = DetalleOrdenCompraBL.ListarDetalleCompraxCodigo(intNumOrden).Tables(0)

            dgDatos.DataSource = CType(Session("myDatatable"), DataTable).DefaultView
            dgDatos.DataBind()

        End If
    End Sub

    Protected Sub btnCancelar_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Response.Redirect("ListaOrdenCompra.aspx")
    End Sub
End Class
